﻿/*********************************************************************************
 *Author:         OnClick
 *Version:        1.0
 *UnityVersion:   2018.3.11f1
 *Date:           2019-04-15
 *Description:    IFramework
 *History:        2018.11--
*********************************************************************************/
using System;
using System.IO;
using UnityEditor;
using UnityEngine;

namespace IFramework
{
    [Serializable]
    public class ABCollectViewItem : IEditorGUI
    {
        public bool Selected;
        public ABCollectType collectType;
        public string searchPath;
        public string searchPattern;
        public SearchOption searchOption = SearchOption.AllDirectories;
        public string bundleName;
        public override void OnGUI(Rect rect, Rect worldRect)
        {
            base.OnGUI(rect, worldRect);
            DrawHorizontal(() => {

                Selected = Toggle(Selected, "", Width(20));
                collectType = (ABCollectType)Popup((int)collectType, Enum.GetNames(typeof(ABCollectType)), Width(rect.width / 8));
                searchOption = (SearchOption)Popup((int)searchOption, Enum.GetNames(typeof(SearchOption)),Width(rect.width / 7));
                searchPattern = TextField(searchPattern, Width(rect.width / 8));
                searchPath = TextField(searchPath, Width(rect.width / 4));
                Button((bo) =>
                {
                    if (bo)
                        searchPath = EditorUtility.OpenFolderPanel("Set", Application.dataPath, "").ToAssetsPath();
                }, "Set", Width(40));
                if (collectType== ABCollectType.ABName)
                    bundleName = TextField(bundleName);
            });
        }
    }
}
